home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 44 / PC Actual CD 44.iso / Linux / Cygwin / full.exe / Disk1 / data1.cab / Tools / H-i586-cygwin32 / i586-cygwin32 / include / mingw32 / stdlib.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-12-04  |  7.1 KB  |  276 lines

  1. /*
  2.  * stdlib.h
  3.  *
  4.  * Definitions for common types, variables, and functions.
  5.  *
  6.  * This file is part of the Mingw32 package.
  7.  *
  8.  * Contributors:
  9.  *  Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
  10.  *
  11.  *  THIS SOFTWARE IS NOT COPYRIGHTED
  12.  *
  13.  *  This source code is offered for use in the public domain. You may
  14.  *  use, modify or distribute it freely.
  15.  *
  16.  *  This code is distributed in the hope that it will be useful but
  17.  *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
  18.  *  DISCLAMED. This includes but is not limited to warranties of
  19.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  20.  *
  21.  * $Revision: 1.3 $
  22.  * $Author: noer $
  23.  * $Date: 1998/10/20 01:24:49 $
  24.  *
  25.  */
  26.  
  27. #ifndef _STDLIB_H_
  28. #define _STDLIB_H_
  29.  
  30. /*
  31.  * RAND_MAX is the maximum value that may be returned by rand.
  32.  * The minimum is zero.
  33.  */
  34. #define    RAND_MAX    0x7FFF
  35.  
  36. /*
  37.  * These values may be used as exit status codes.
  38.  */
  39. #define    EXIT_SUCCESS    0
  40. #define    EXIT_FAILURE    -1
  41.  
  42. /*
  43.  * Definitions for path name functions.
  44.  * NOTE: All of these values have simply been chosen to be conservatively high.
  45.  *       Remember that with long file names we can no longer depend on
  46.  *       extensions being short.
  47.  */
  48. #ifndef __STRICT_ANSI__
  49.  
  50. #ifndef MAX_PATH
  51. #define    MAX_PATH    (260)
  52. #endif
  53.  
  54. #define    _MAX_PATH    MAX_PATH
  55. #define    _MAX_DRIVE    (3)
  56. #define    _MAX_DIR    256
  57. #define    _MAX_FNAME    256
  58. #define    _MAX_EXT    256
  59.  
  60. #endif    /* Not __STRICT_ANSI__ */
  61.  
  62.  
  63. #ifndef RC_INVOKED
  64.  
  65. #ifdef __cplusplus
  66. extern "C" {
  67. #endif
  68.  
  69. /*
  70.  * This seems like a convenient place to declare these variables, which
  71.  * give programs using WinMain (or main for that matter) access to main-ish
  72.  * argc and argv. environ is a pointer to a table of environment variables.
  73.  * NOTE: Strings in _argv and environ are ANSI strings.
  74.  */
  75. extern int    _argc;
  76. extern char**    _argv;
  77.  
  78. /*
  79.  * Use environ from the DLL, not as a global. 
  80.  */
  81.  
  82. #ifdef __MSVCRT__
  83.    extern char *** __p__environ();
  84. #  define _environ (*__p__environ())
  85. #else /* ! __MSVCRT__ */
  86.    extern char *** __imp__environ_dll;
  87. #  define _environ (*__imp__environ_dll)
  88. #endif /* ! __MSVCRT__ */
  89.  
  90. #define environ _environ
  91.  
  92. #ifdef    __MSVCRT__
  93. /* One of the MSVCRTxx libraries */
  94. extern int*    __imp__sys_nerr;
  95. #define    sys_nerr    (*__imp__sys_nerr)
  96. #else
  97. /* CRTDLL run time library */
  98. extern int*    __imp__sys_nerr_dll;
  99. #define sys_nerr    (*__imp__sys_nerr_dll)
  100. #endif
  101.  
  102. extern char**    __imp__sys_errlist;
  103. #define    sys_errlist    (__imp__sys_errlist)
  104.  
  105. /*
  106.  * OS version and such constants.
  107.  */
  108. #ifndef __STRICT_ANSI__
  109.  
  110. #ifdef    __MSVCRT__
  111. /* msvcrtxx.dll */
  112.  
  113. extern unsigned int*    __p__osver();
  114. extern unsigned int*    __p__winver();
  115. extern unsigned int*    __p__winmajor();
  116. extern unsigned int*    __p__winminor();
  117.  
  118. #define _osver        (*__p__osver())
  119. #define _winver        (*__p__winver())
  120. #define _winmajor    (*__p__winmajor())
  121. #define _winminor    (*__p__winminor())
  122.  
  123. #else
  124. /* Not msvcrtxx.dll, thus crtdll.dll */
  125.  
  126. extern unsigned int*    _imp___osver_dll;
  127. extern unsigned int*    _imp___winver_dll;
  128. extern unsigned int*    _imp___winmajor_dll;
  129. extern unsigned int*    _imp___winminor_dll;
  130.  
  131. #define _osver        (*_imp___osver_dll)
  132. #define _winver        (*_imp___winver_dll)
  133. #define _winmajor    (*_imp___winmajor_dll)
  134. #define _winminor    (*_imp___winminor_dll)
  135.  
  136. #endif
  137.  
  138. #endif /* Not __STRICT_ANSI__ */
  139.  
  140.  
  141. #define __need_size_t
  142. #define __need_wchar_t
  143. #define __need_NULL
  144. #include <stddef.h>
  145.  
  146. #ifdef    __GNUC__
  147. #define    _ATTRIB_NORETURN    __attribute__ ((noreturn))
  148. #else    /* Not __GNUC__ */
  149. #define    _ATTRIB_NORETURN
  150. #endif    /* __GNUC__ */
  151.  
  152. double    atof    (const char* szNumber);
  153. int    atoi    (const char* szNumber);
  154. long    atol    (const char* szNumber);
  155.  
  156.  
  157. double    strtod    (const char* szNumber, char** pszAfterNumber);
  158. double    wcstod    (const wchar_t* wsNumber, wchar_t** pwsAfterNumber);
  159. long    strtol    (const char* szNumber, char** pszAfterNumber, int nBase);
  160. long    wcstol    (const wchar_t* wsNumber, wchar_t** pwsAfterNumber, int nBase);
  161.  
  162. unsigned long    strtoul    (const char* szNumber, char** pszAfterNumber,
  163.             int nBase);
  164. unsigned long    wcstoul (const wchar_t* wsNumber, wchar_t** pwsAfterNumber,
  165.             int nBase);
  166.  
  167. size_t    wcstombs    (char* mbsDest, const wchar_t* wsConvert, size_t size);
  168. int    wctomb        (char* mbDest, wchar_t wc);
  169.  
  170. int    mblen        (const char* mbs, size_t sizeString);
  171. size_t    mbstowcs    (wchar_t* wcaDest, const char* mbsConvert,
  172.              size_t size);
  173. int    mbtowc        (wchar_t* wcDest, const char* mbConvert, size_t size);
  174.  
  175. int    rand    ();
  176. void    srand    (unsigned int nSeed);
  177.  
  178. void*    calloc    (size_t sizeObjCnt, size_t sizeObject);
  179. void*    malloc    (size_t    sizeObject);
  180. void*    realloc    (void* pObject, size_t sizeNew);
  181. void    free    (void* pObject);
  182.  
  183. void    abort    () _ATTRIB_NORETURN;
  184. void    exit    (int nStatus) _ATTRIB_NORETURN;
  185. int    atexit    (void (*pfuncExitProcessing)());
  186.  
  187. int    system    (const char* szCommand);
  188. char*    getenv    (const char* szVarName);
  189.  
  190. typedef    int (*_pfunccmp_t)(const void*, const void*);
  191.  
  192. void*    bsearch    (const void* pKey, const void* pBase, size_t cntObjects,
  193.         size_t sizeObject, _pfunccmp_t pfuncCmp);
  194. void    qsort    (const void* pBase, size_t cntObjects, size_t sizeObject,
  195.         _pfunccmp_t pfuncCmp);
  196.  
  197. int    abs    (int n);
  198. long    labs    (long n);
  199.  
  200. /*
  201.  * div_t and ldiv_t are structures used to return the results of div and
  202.  * ldiv.
  203.  *
  204.  * NOTE: div and ldiv appear not to work correctly unless
  205.  *       -fno-pcc-struct-return is specified. This is included in the
  206.  *       mingw32 specs file.
  207.  */
  208. typedef struct { int quot, rem; } div_t;
  209. typedef struct { long quot, rem; } ldiv_t;
  210.  
  211. div_t    div    (int nNumerator, int nDenominator);
  212. ldiv_t    ldiv    (long lNumerator, long lDenominator);
  213.  
  214.  
  215. #ifndef    __STRICT_ANSI__
  216.  
  217. /*
  218.  * NOTE: Officially the three following functions are obsolete. The Win32 API
  219.  *       functions SetErrorMode, Beep and Sleep are their replacements.
  220.  */
  221. void    _beep (unsigned int, unsigned int);
  222. void    _seterrormode (int nMode);
  223. void    _sleep (unsigned long ulTime);
  224.  
  225. void    _exit    (int nStatus) _ATTRIB_NORETURN;
  226.  
  227. int    _putenv    (const char* szNameEqValue);
  228. void    _searchenv (const char* szFileName, const char* szVar,
  229.         char* szFullPathBuf);
  230.  
  231. char*    _itoa (int nValue, char* sz, int nRadix);
  232. char*    _ltoa (long lnValue, char* sz, int nRadix);
  233.  
  234. char*    _ecvt (double dValue, int nDig, int* pnDec, int* pnSign);
  235. char*    _fcvt (double dValue, int nDig, int* pnDec, int* pnSign);
  236. char*    _gcvt (double dValue, int nDec, char* caBuf);
  237.  
  238. void    _makepath (char* caPath, const char* szDrive, const char* szDir,
  239.         const char* szName, const char* szExtension);
  240. void    _splitpath (const char* szPath, char* caDrive, char* caDir,
  241.         char* caName, char* caExtension);
  242. char*    _fullpath (char* caBuf, const char* szPath, size_t sizeMax);
  243.  
  244. #ifndef    _NO_OLDNAMES
  245. void    beep (unsigned int, unsigned int);
  246. void    seterrormode (int nMode);
  247. void    sleep (unsigned long ulTime);
  248.  
  249. int    putenv (const char* szNameEqValue);
  250. void    searchenv (const char* szFileName, const char* szVar,
  251.         char* szFullPathBuf);
  252.  
  253. char*    itoa (int nValue, char* sz, int nRadix);
  254. char*    ltoa (long lnValue, char* sz, int nRadix);
  255.  
  256. char*    ecvt (double dValue, int nDig, int* pnDec, int* pnSign);
  257. char*    fcvt (double dValue, int nDig, int* pnDec, int* pnSign);
  258. char*    gcvt (double dValue, int nDec, char* caBuf);
  259. #endif    /* Not _NO_OLDNAMES */
  260.  
  261. #endif    /* Not __STRICT_ANSI__ */
  262.  
  263. /*
  264.  * Undefine the no return attribute used in some function definitions
  265.  */
  266. #undef    _ATTRIB_NORETURN
  267.  
  268. #ifdef __cplusplus
  269. }
  270. #endif
  271.  
  272. #endif    /* Not RC_INVOKED */
  273.  
  274. #endif    /* Not _STDLIB_H_ */
  275.  
  276.